home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Workspace / WrapperInspector / Source / SoundSubInspector.m < prev    next >
Text File  |  1995-06-12  |  3KB  |  104 lines

  1. //----------------------------------------------------------------------------------------------------
  2. //
  3. //    SoundSubInspector
  4. //
  5. //    Inherits From:        DefaultSubInspector
  6. //
  7. //    Declared In:        SoundSubInspector.h
  8. //
  9. //    Disclaimer
  10. //
  11. //        You may freely copy, distribute and reuse this software and its
  12. //        associated documentation. I disclaim any warranty of any kind, 
  13. //        expressed or implied, as to its fitness for any particular use.
  14. //
  15. //----------------------------------------------------------------------------------------------------
  16. #import "SoundSubInspector.h"
  17. #import <appkit/appkit.h>
  18.  
  19.  
  20. @implementation SoundSubInspector
  21.  
  22. static id     _SELF = nil;
  23.  
  24. //----------------------------------------------------------------------------------------------------
  25. //  Initialization and Free Methods
  26. //----------------------------------------------------------------------------------------------------
  27. + new
  28. {
  29.     // Only allow one instance... 
  30.         
  31.         if (_SELF) return _SELF;
  32.         _SELF = self = [super new];
  33.     sound = [[Sound alloc] init];
  34.      return _SELF;
  35. }
  36.  
  37.  
  38. - free
  39. {
  40.     if (sound)  [sound free];
  41.     return [super free];
  42. }
  43.  
  44.  
  45. //----------------------------------------------------------------------------------------------------
  46. //  Inspection Methods
  47. //----------------------------------------------------------------------------------------------------
  48. - inspect: (STR) path
  49. {
  50.     //  Read the soundfile and display information...
  51.     
  52.     int    readStatus;
  53.     
  54.     if (! path) return self;
  55.  
  56.     readStatus = [sound readSoundfile: path];
  57.     if (readStatus != SND_ERR_NONE)
  58.         {
  59.         [sound deleteSamples];
  60.         return [self inspectionError: path];
  61.         }
  62.     
  63.     [size setIntValue: [sound dataSize]];
  64.     [samples setIntValue: [sound sampleCount]];
  65.     [seconds setFloatValue: [sound duration]];
  66.     [format setIntValue: [sound dataFormat]];
  67.     [rate setDoubleValue: [sound samplingRate]];
  68.     [channels setIntValue: [sound channelCount]];
  69.     [info setStringValue: [sound info]];
  70.  
  71.     return self;
  72. }
  73.  
  74.  
  75. //----------------------------------------------------------------------------------------------------
  76. //  Action Methods
  77. //----------------------------------------------------------------------------------------------------
  78. - play: sender
  79. {
  80.     [sound play];
  81.     return self;
  82. }
  83.  
  84.  
  85. //----------------------------------------------------------------------------------------------------
  86. //  Accessing Inspection View
  87. //----------------------------------------------------------------------------------------------------
  88. - clearInspectorView
  89. {
  90.     //  Clear view before...
  91.     
  92.     [size setStringValue: ""];
  93.     [samples setStringValue: ""];
  94.     [seconds setStringValue: ""];
  95.     [format setStringValue: ""];
  96.     [rate setStringValue: ""];
  97.     [channels setStringValue: ""];
  98.     [info setStringValue: ""];
  99.  
  100.     return self;
  101. }
  102.  
  103.  
  104. @end